package xyz.xtt.exchange.constants;

import java.util.concurrent.TimeUnit;

import xyz.xtt.common.starter.cache.CacheConfig;
import xyz.xtt.exchange.entity.TblArtAmberCard;
import xyz.xtt.exchange.entity.TblAssetUserConfig;
import xyz.xtt.exchange.entity.TblAssetUserLog;
import xyz.xtt.exchange.entity.TblCarouseImage;
import xyz.xtt.exchange.response.ArtAmberCardResponse;
import xyz.xtt.exchange.vo.AssetTypeResponseVo;
import xyz.xtt.exchange.vo.HomeTopResponse;
import xyz.xtt.exchange.vo.NftListVo;
import xyz.xtt.exchange.vo.PhoneRegionVo;
import xyz.xtt.exchange.vo.QueryCollectionResponseVo;

/**
 * 缓存类枚举
 *
 * @author huqibo
 * @date 2024/11/28
 */
public enum ExchangeCache implements CacheConfig {
	/**
	 * 个人风格明细
	 */
	COLL_QUERY_TYPE("colltype", 1, TimeUnit.DAYS, QueryCollectionResponseVo.class),
	/**
	 * 资产分类
	 */
	ASSET_TYPE("assettype", 1, TimeUnit.DAYS, AssetTypeResponseVo.class),
	/**
	 * 首页
	 */
	HOME_TOP("homeTop", 1, TimeUnit.DAYS, HomeTopResponse.class),

	/**
	 * 首页banner
	 */
	HOME_BANNER("homeBanner", 1, TimeUnit.DAYS, TblCarouseImage.class), INDEX_LIST("indexList", 1, TimeUnit.MINUTES, NftListVo.class),

	USER_LIKE_SET("tblUserLike", 1, TimeUnit.DAYS, TblCarouseImage.class),

	/**
	 * 靓号归属地列表
	 */
	LUCK_PHONE_REGION_LIST("luckPhoneRegionList", 1, TimeUnit.HOURS, PhoneRegionVo.class),
	/**
	 * 艺术卡缓存
	 */
	QUERY_ART_CARD_WITH_UID("queryArtCardWithUid", 1, TimeUnit.DAYS, TblArtAmberCard.class),

	/**
	 * 收藏缓存
	 */
	AssetLike("assetLike", 1, TimeUnit.DAYS, ArtAmberCardResponse.class),

	/**
	 * 操作日志, 最后一条
	 */
	TBL_ASSET_USER_LOG("tblAssetUserLog", 1, TimeUnit.DAYS, TblAssetUserLog.class),
	/**
	 * 用户资产相关设置
	 */
	TBL_ASSET_USER_CONFIG("tblAssetUserConfig", 1, TimeUnit.DAYS, TblAssetUserConfig.class),

	;

	/**
	 * 缓存key前缀
	 */
	private String prefix;
	/**
	 * 缓存时长
	 */
	private long ttl;
	/**
	 * 缓存时长单位
	 */
	private TimeUnit timeUnit;
	/**
	 * 缓存序列化对象类型
	 */
	private Class<?> clazz;

	private <T> ExchangeCache(String prefix, long ttl, TimeUnit timeUnit, Class<T> clazz) {
		this.prefix = prefix;
		this.ttl = ttl;
		this.timeUnit = timeUnit;
		this.clazz = clazz;
	}

	@Override
	public String prefix() {
		return prefix;
	}

	@Override
	public long ttl() {
		return ttl;
	}

	@Override
	public TimeUnit timeUnit() {
		return timeUnit;
	}

	@Override
	public Class<?> clazz() {
		return clazz;
	}

}
